<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->
<section id="main-content">
    <section class="wrapper">
        <h3><i class="fa fa-angle-right"></i> 添加/修改视频课程信息</h3>

        <!-- BASIC FORM ELELEMNTS -->
        <div class="row mt">
            <div class="col-lg-12">
                <div class="form-panel">
                    <h4 class="mb">
                        <i class="fa fa-angle-right"></i> 视频课程信息
                        <a class="btn btn-theme btn-default" href="{:U('index',array('currpage'=>$currpage))}">返回</a>
                    </h4>

                    <form id="myForm" class="form-horizontal style-form" method="post" action="{:U('add')}"  enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">展示图<span style="color: red;">(250px*160px)</span></label>
                            <div class="col-sm-10">
                                <input type="file" name="one" id="avatar" onchange='PreviewImage(this)' style="opacity: 0;display: block;cursor:pointer" />
                                <if condition="$list.img != NULL">
                                    <img class="ph-user"  src="{$list.img}" width="80" height="60" onclick="openFile()" style="cursor:pointer">
                                    <else/>
                                    <img class="ph-user" src="__PUBLIC__/img/wutu.png" alt="" width="80" height="80" onclick="openFile()" style="cursor:pointer">
                                </if>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">教师</label>
                            <div class="col-sm-10">
                                <select  name="teacher_id" class="form-control">
                                    <option value="0">请选择授课老师</option>
                                    <foreach name="teacher" item="v">
                                        <option value="{$v.id}" <if condition="$list['teacher_id'] == $v['id']">selected</if>>{$v.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">课程类型</label>
                            <div class="col-sm-10">
                                <select  name="shou_type" class="form-control">
                                    <option value="0">请选择课程类型</option>
                                    <foreach name="shou_type" item="v">
                                        <option value="{$v.id}" <if condition="$list['shou_type'] == $v['id']">selected</if>>{$v.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label"><span style="color: red;">*</span>课程类别</label>
                            <div class="col-sm-10">
                                <select id="goods_one" name="goods_one" class="form-control" style="width: 50%;">
                                    <option value="0">请选择商品类别</option>
                                    <foreach name="mei_type" item="v">
                                        <option value="{$v.id}" <if condition="$list['type_one_id'] == $v['id']">selected</if>>{$v.name}</option>
                                    </foreach>
                                </select>
                            </div>
                            <div class="col-sm-10">
                                <select id="goods_two" name="goods_two" class="form-control" style="width: 50%;margin-left: -225px;">
                                    <option value="0">请选择商品类别</option>
                                    <foreach name="type_two_id" item="v">
                                        <option value="{$v.id}" <if condition="$list['type_two_id'] == $v['id']">selected</if>>{$v.name}</option>
                                    </foreach>
                                </select>
                            </div>
                            <div class="col-sm-10">
                                <select id="goods_three" name="goods_three" class="form-control" style="width: 50%;margin-left: -451px;">
                                    <option value="0">请选择商品类别</option>
                                    <foreach name="type_three_id" item="v">
                                        <option value="{$v.id}" <if condition="$list['type_three_id'] == $v['id']">selected</if>>{$v.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">课程标题/名称</label>
                            <div class="col-sm-10">
                                <input id="name" name="title" value="{$list.title}" type="text"  class="form-control" placeholder="请输入课程标题/名称">
                                <!--<div>您还可以写<span  id="result">20</span>/20个字</div>-->
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">课程总章节数</label>
                            <div class="col-sm-10">
                                <input name="nums" value="{$list.nums}" type="number"  class="form-control" placeholder="请输入课程总章节数">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">课程价格</label>
                            <div class="col-sm-10">
                                <input  name="moneys" value="{$list.moneys}" type="number"
                                       class="form-control" placeholder="请输入课程价格">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">分享人数</label>
                            <div class="col-sm-10">
                                <input name="shared" value="{$list.shared}" type="number"  class="form-control" placeholder="请输入分享人数">
                            </div>
                            <span style="color: red;">用户分享达标即可免费学习该视频，无需分享请不要填写</span>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">分享标语</label>
                            <div class="col-sm-10">
                                <input name="poster" value="{$list.poster}" type="text"  class="form-control" placeholder="请输入分享标语">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">学习人数</label>
                            <div class="col-sm-10">
                                <input name="xiao" value="{$list.xiao}" type="number"  class="form-control" placeholder="请输入学习人数">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">最高使用积分数</label>
                            <div class="col-sm-10">
                                <input id="covers"  name="covers" value="{$list.covers}" type="number"  class="form-control" placeholder="请输入最高使用积分数">
                            </div>
                            <span>积分核销比例：{$covers_shu.nums_seven}</span>
                            <div>抵扣金额：<span  id="result" style="color: red;font-weight: bold;">0</span>元</div>
                        </div>
                        <div id="contents" class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">课程详细介绍</label>
                            <div class="col-sm-10">
                                <textarea id="intro" name="intro" class="input">{$list.intro}</textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">名师精品课</label>
                            <div class="col-sm-10" id="type">
                                <input id="two" type="radio" name="tui" value="1" <if condition="$list.tui eq 1">checked<else/>checked</if> style="width:30px;height:30px">不设置为名师精品课
                                <input id="one" type="radio" name="tui" value="2" <if condition="$list.tui eq 2">checked</if> style="width:30px;height:30px;margin-left: 20px;">设置为名师精品课
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">每日精选</label>
                            <div class="col-sm-10">
                                <input  type="radio" name="jing" value="1" <if condition="$list.jing eq 1">checked<else/>checked</if> style="width:30px;height:30px">不设置为每日精选
                                <input  type="radio" name="jing" value="2" <if condition="$list.jing eq 2">checked</if> style="width:30px;height:30px;margin-left: 20px;">设置为每日精选
                            </div>
                        </div>
                        <input type="hidden"  name="id"       value="{$list.id}">
                        <input type="hidden"  name="imgs"     value="{$list.img}">
                        <input type="hidden"  name="currpage" value="{$currpage}">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label"></label>
                            <div class="col-sm-10">
                                <input  type="submit" id="tianjia" class="btn btn-theme" value="保存" style="width: 150px;margin-left: 60px">
                                <input  type="reset" class="btn btn-warning" value="重置" style="width: 150px">
                            </div>
                        </div>
                    </form>
                    <input type="hidden" id="nums_seven" value="{$covers_shu.nums_seven}">
                </div>
            </div><!-- col-lg-12-->
        </div><!-- /row -->
    </section>
</section>

<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh_CN.js"></script>
<script>
    //商品类别
    $("#goods_one").change(function(){
        var goods_one   = $("#goods_one").val();
        if(goods_one < 1){
            layer.open({
                title: '提示',
                content: "请选择分类",
            });
        }else{
            $.ajax({
                type:"post",
                url:"{:U('sou')}",
                data:{goods_type:goods_one},
                success:function (res) {
                    $('#goods_two').html('');
                    $('#goods_three').html('');
                    var arr = "";
                    if(res.info == 1){
                        arr += "<option value='0'>暂无二级分类</option>"
                    }else{
                        $.each(res.info,function(i,n){
                            arr += "<option value="+n["id"]+">"+n['name']+"</option>"
                        });
                    }
                    $("#goods_two").append(arr);
                    var arrs = "";
                    if(res.infos == 1){
                        arrs += "<option value='0'>暂无三级分类</option>"
                    }else{
                        $.each(res.infos,function(i,n){
                            arrs += "<option value="+n["id"]+">"+n['name']+"</option>"
                        });
                    }
                    $("#goods_three").append(arrs);
                }
            })
        }
    });
    $("#goods_two").change(function(){
        var goods_two   = $("#goods_two").val();
        if(goods_two < 1){
            layer.open({
                title: '提示',
                content: "请选择分类",
            });
        }else{
            $.ajax({
                type:"post",
                url:"{:U('sous')}",
                data:{goods_type:goods_two},
                success:function (res) {
                    $('#goods_three').html('');
                    var arrs = "";
                    if(res.infos == 1){
                        arrs += "<option value='0'>暂无三级分类</option>"
                    }else{
                        $.each(res.infos,function(i,n){
                            arrs += "<option value="+n["id"]+">"+n['name']+"</option>"
                        });
                    }
                    $("#goods_three").append(arrs);
                }
            })
        }
    });
    $("#covers").bind('input',function(){
        var nums_seven = $("#nums_seven").val();
        var bb=$('#covers').val();//
        var zui =  Math.floor(nums_seven*bb);
        $('#result').html(zui);
    })
    //提示
    $('.gui_twos').mouseenter(function(){$('.gui_two').show();});
    $('.gui_twos').mouseleave(function(){$('.gui_two').hide();});
    $('.yuans').mouseenter(function(){$('.yuan').show();});
    $('.yuans').mouseleave(function(){$('.yuan').hide();});
    $('.mons').mouseenter(function(){$('.mon').show();});
    $('.mons').mouseleave(function(){$('.mon').hide();});
    //编辑器
    var editor;
    KindEditor.ready(function(e){
        editor = e.create("[name=intro]",{
            "width":"700px",
            "height":"300px",
            allowFileManager:true, //允许对上传图片进行管理
            "items":["source", "|", "undo", "redo", "|", "preview","|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "insertorderedlist", "insertunorderedlist", "indent", "outdent", "subscript", "superscript", "clearhtml","|","formatblock", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline","|", "image"]
        });
    });
   /* $("#tianjia").click(function(){
        editor.sync();
        var goods_type_id = $("#goods_type_id").val();
        var name          = $("#name").val();
        var yuan_moneys   = $("#yuan_moneys").val();
        var lei           = $("#lei").val();
        var intro         = $("#intro").val();
        console.log(goods_type_id,name,yuan_moneys,lei,intro);
        if(!name || (goods_type_id < 1) || !yuan_moneys || !lei || !intro){
            layer.open({
                title: '添加/修改提示：',content: '课程信息请填写完整'
            });
        }else{
            $("#myForm").submit();
        }
    });*/
    //图片上传
    function openFile(){
        return  $("#avatar").click();
    }
    function PreviewImage(imgFile) {
        var filextension=imgFile.value.substring(imgFile.value.lastIndexOf("."),imgFile.value.length);
        var o=imgFile.files[0];
        filextension=filextension.toLowerCase();
        if ((filextension!='.jpg')&&(filextension!='.jpeg')&&(filextension!='.png')&&(filextension!='.bmp'))
        {

            imgFile.focus();
        }else if(o.size > 2097152){
            imgFile.focus();
        }
        else
        {
            var path;
            path=window.URL.createObjectURL(imgFile.files[0]);// FF 7.0以上
            $('.ph-user').attr({src:path});
        }
    }

</script>

</body>
</html>


